﻿using System.ServiceModel;

namespace MsmqWindowsService
{
    public partial class Service : System.ServiceProcess.ServiceBase
    {
        private ServiceHost serviceHost;

        public Service()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
            }
            serviceHost = new ServiceHost(typeof(SilenthinkService.MsmqService));
           serviceHost.Open();
        }

        protected override void OnStop()
        {
            if (serviceHost == null) return;
            serviceHost.Close();
            serviceHost = null;
        }
    }
}
